import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:meal/components/evaluate/customer.dart';
import 'package:meal/components/evaluate/mine.dart';
import 'package:meal/constant/fonts.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

///
/// 评价管理
///
class EvaluateManage extends StatefulWidget {
  const EvaluateManage({Key? key}) : super(key: key);

  @override
  State<EvaluateManage> createState() => _EvaluateManageState();
}

class _EvaluateManageState extends State<EvaluateManage> {
  bool oneself = false;


  Widget get actions {
    return IconButton(
        icon: ImageIcon(ToolsUtils.assetImageIcon('date.png')),
        iconSize: Sizes.default18,
        onPressed: () {
          BrnDateRangePicker.showDatePicker(context,
              isDismissible: true,
              minDateTime: DateTime(2019, 01, 01),
              maxDateTime: DateTime(2030, 12, 30),
              pickerMode: BrnDateTimeRangePickerMode.date,
              minuteDivider: 10,
              pickerTitleConfig: const BrnPickerTitleConfig(titleContent: '选择日期范围'),
              dateFormat: 'yyyy-MM-dd',
              initialStartDateTime: DateTime(2020, 06, 21, 11, 00, 00),
              initialEndDateTime: DateTime(2020, 06, 23, 10, 00, 00),
              themeData: BrnPickerConfig(
                  titleTextStyle: BrnTextStyle(
                      color: ColorsUtils.parseColorFromHexString(ColorsUtils.color333),
                      fontSize: Sizes.default15,
                      fontWeight: Fonts.w5)), onConfirm: (DateTime startDateTime,
                  DateTime endDateTime, List<int> startList, List<int> endList) {
            BrnToast.show('onConfirm: $startDateTime $endDateTime $startList $endList', context);
          });
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.customBrnAppBar(titleBox(), actions: actions),
      body: oneself ? const MineEvaluate() : const CustomerEvaluate()
    );
  }

  Widget titleBox() {
    return SizedBox(
      width: 200,
      height: 32,
      child: Row(
        children: [
          Expanded(
              child: InkWell(
            onTap: () {
              setState(() {
                oneself = false;
              });
            },
            child: Container(
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  color: oneself
                      ? ColorsUtils.rgba(252, 161, 144, 1)
                      : ColorsUtils.rgba(255, 255, 255, 1),
                  borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(16), bottomLeft: Radius.circular(16))),
              child: Text(
                '顾客评价',
                style: StylesUtils.customTextStyle(
                  color: oneself ? ColorsUtils.colorFaf : ColorsUtils.colorFf6,
                ),
              ),
            ),
          )),
          Expanded(
              child: InkWell(
            onTap: () {
              setState(() {
                oneself = true;
              });
            },
            child: Container(
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  color: !oneself
                      ? ColorsUtils.rgba(252, 161, 144, 1)
                      : ColorsUtils.rgba(255, 255, 255, 1),
                  borderRadius: const BorderRadius.only(
                      topRight: Radius.circular(16), bottomRight: Radius.circular(16))),
              child: Text('我的评价',
                  style: StylesUtils.customTextStyle(
                    color: !oneself ? ColorsUtils.colorFaf : ColorsUtils.colorFf6,
                  )),
            ),
          ))
        ],
      ),
    );
  }

}


